<template>
<div>
  批量生成ID
  <p>id起始代码（复制lst最后一个代码粘贴进来即可，会自动+1）<Input type="number" v-model="startNum"/></p>
  <p>路径（文件路径，不需要加反引号，用换行分割）<textarea name="" cols="30" rows="10" v-model="allPath"></textarea></p>
  <Button @click="generate">生成</Button>
  <textarea cols="30" rows="10" v-model="result"/>
</div>
</template>

<script>
export default {
  name: "idGenerate",
  data() {
    return{
      startNum: 0,
      allPath: 'character/demoniclancer/lele906127695/beamspear/114020120.equ\n' +
          'character/demoniclancer/lele906127695/halberd/114010082.equ\n' +
          'character/demoniclancer/lele906127695/javelin/114030113.equ\n' +
          'character/demoniclancer/lele906127695/pike/114000096.equ',
      result: ''
    }
  },
  methods: {
    generate(){
      this.result = ''
      //获取文件路径且不为空
      if(this.allPath === '' || !this.allPath){
        this.$Message.error({ content: '装备代码不能为空' })
        return
      }
      let firstArr = this.allPath.split('\n')
      let lineStr = ''
      let id = this.startNum+1
      for(let i in firstArr) {
        //路径加入反引号
        this.result = this.result + id + '\t' + '`'+firstArr[i]+'`\n'
        id++
      }
      this.$Message.success({ content: '生成成功' })
    },
  }
}
</script>

<style scoped>

</style>
